package com.java.system.common.entity.admin.handler;

/*import com.alibaba.fastjson.JSONArray;*/
import net.minidev.json.JSONArray;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 * @ClassName: DetailTypeHandler
 * @Description: json类型转换器
 * @Version: v1.0.0
 * @Author: yangyuwei
 * @Date: 2019/7/30
 * Modification History:
 * Date             Author      Version     Description
 * -------------------------------------------------------------
 * 2019/7/30      yangyuwei      v1.0.0      创建
 */
/*
public class DetailTypeHandler extends BaseTypeHandler<List<Detail>> {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, List<Detail> parameter, JdbcType jdbcType) throws SQLException {
        ps.setString(i, JSONArray.toJSONString(parameter));
    }

   */
/* @Override
    public List<Detail> getNullableResult(ResultSet rs, String columnName) throws SQLException {
        return JSONArray.parseArray(rs.getString(columnName), Detail.class);
    }

    @Override
    public List<Detail> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        return JSONArray.parseArray(rs.getString(columnIndex), Detail.class);
    }

    @Override
    public List<Detail> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        return JSONArray.parseArray(cs.getString(columnIndex), Detail.class);
    }

    public static void main(String[] args) {
        List<Detail> details = JSONArray.parseArray("[{\"href\": \"www.baidu.com\", \"method\": \"get\"}]", Detail.class);
        System.out.println(details);
    }*//*

}*/
